<?php
namespace app\decorate\model;
use app\BaseModel;
use think\facade\Db;



class IndexSiteIv extends BaseModel
{
    //定义表名 工地表
    protected $name = 'longbing_card_decorate_iv';


    /**
     * User: chenniang
     * Date: 2019-10-17 18:14
     * @return void
     * descption:浏览记录
     */
    public function ivSelect($dis){
        $data = $this
            ->alias('a')
            ->leftJoin('longbing_card_user b',"a.user_id = b.id AND avatarUrl != ''")
            ->where($dis)
            ->order('a.create_time desc')
            ->field(['a.id','b.avatarUrl'])
            ->limit(8)
            ->select()
            ->toArray();
        return $data;
    }

    /**
     * @param $data
     * @return int|string
     * 添加浏览记录
     */
    public function ivAdd($data){
        $data['create_time'] = time();
        $res = $this->insert($data);
        return $res;
    }
    /**
     * @param $dis
     * @param $data
     * @return AdminCate
     * 编辑浏览记录
     */
    public function ivUpdate($dis,$data){
        $data['create_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;
    }

    /**
     * User: chenniang
     * Date: 2019-10-17 18:37
     * @param $dis
     * @return array|\think\Model|null
     * descption:查找记录
     */
    public function ivInfo($dis){
        return $this->where($dis)->find();
    }




}